package com.zttek.videoShareProject.common.keyword;

import com.zttek.videoShareProject.modules.model.Keyword;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class CommentUttil {
    /**
     * 检查关键字
     * @param context
     * @return
     */
    public static String checkContext(String context){
        /*待实现*/
        return context;
    }

    /**
     * 检查关键字
     * @param context
     * @return
     */
    public static String checkContext(String context, List<Keyword> list){
        /*待实现*/
        Set<String> ketwordSet = new HashSet<String>();
        for(Keyword keyword:list){
            ketwordSet.add(keyword.getKeyword());
        }
        SensitivewordFilter filter = null;
        if(ketwordSet.size()!=0){
            filter = new SensitivewordFilter(ketwordSet);//初始化关键字库
        }else{
            filter = new SensitivewordFilter();//初始化关键字库
        }
        String result = filter.replaceSensitiveWord(context,1,"*");
        return result;
    }
}
